# -*- coding: utf-8 -*-
import os
import sys
import random
import time
import Mk_soldier
import liberate

#player'sname choose
player_name = ['chen chaoxi', 'hu lin','xia chenliang', 'xiang zhihua']
while True:
    print('choose your soldier :')
    for i in range(0, len(player_name)):
        print('\t%s.\033[35m%s\033[0m' % (i, player_name[i].title()))
    try:
        player_choose = int(input('you choose : '))
        if player_choose > 3 or player_choose < 0:
            print('Please input 0~3!again~')
            continue
        break
    except ValueError:
        print("\nPlease input number 0~3")
        continue
player_a_name = player_name[player_choose].title()
a_track = Mk_soldier.Hurter(player_a_name)

#computer'sname choose
computer_name = ['xiong da', 'tian xianbaby', 'ge sila','zombie']
n = int(100 * random.random()) % 4
b_track = Mk_soldier.Superman(computer_name[n].title())

#game body
times = 1
print("Bit game is beginning!\n\033[35m%s\033[0m \033[1mVS\033[0m \033[35m%s\033[0m" % (player_name[player_choose].title(),computer_name[n].title()))
time.sleep(2)
b_track.magic = 2
print("Welcome \033[35m%s\033[0m !\tBlood is : \033[32m%s\033[0m\tMagic is : \033[34m%s\033[0m" % (a_track.soldier_name, a_track.blood, a_track.magic))
print("\033[35m%s\033[0m\'s skills : \033[34m%s\033[0m\n" % (a_track.soldier_name,a_track.skills))
print("Welcome \033[35m%s\033[0m !\tBlood is : \033[32m%s\033[0m\tMagic is : \033[34m%s\033[0m" % (b_track.soldier_name, b_track.blood, b_track.magic))
print("\033[35m%s\033[0m\'s skills : \033[34m%s\033[0m\n" % (b_track.soldier_name,b_track.skills))
time.sleep(2)
#a_track.blood = 60
#a_track.magic = 6
#a_track.dizziness_stu = 1
#a_track.silence_stu = 0
#a_track.poison_stu = 0
#b_track.blood = 30
#b_track.poison_stu = 0
#b_track.magic = 5

while True:
    print("This is \033[36m%s\033[0m time." % str(times))
    print("============================================")
    a_track_en_skill = liberate.enable_skills(a_track.magic, a_track.skills)
    a_track.health_discribe()
    time.sleep(2)
    a_track.blood,a_track.poison_stu = liberate.during_poison_fun(a_track.blood, a_track.poison_stu, a_track.soldier_name)
    if a_track.blood == 0:
        a_track.death_discribe()
        b_track.winner_discribe()
        break
    time.sleep(2)

    a_track.magic, a_track.blood, b_track.blood, a_track.dizziness_stu, a_track.silence_stu, a_track.poison_stu,\
        b_track.dizziness_stu, b_track.silence_stu, b_track.poison_stu, a_skill_name = \
        liberate.user_liberate_skills(a_track.magic, a_track.blood, b_track.blood,
                      a_track.dizziness_stu, a_track.silence_stu, a_track.poison_stu,
                      b_track.dizziness_stu, b_track.silence_stu, b_track.poison_stu,
                      a_track.soldier_name,b_track.soldier_name,a_track.skills)
    if b_track.blood == 0:
        b_track.death_discribe()
        a_track.winner_discribe()
        break

    if a_track.dizziness_stu == 0 and a_skill_name == 'pk_info':
        b_track.blood = a_track.pk_info(b_track.blood, a_track.soldier_name, b_track.soldier_name)
    else:
        pass
    if b_track.blood == 0:
        b_track.death_discribe()
        a_track.winner_discribe()
        break

    a_track.dizziness_stu = liberate.during_dizziness_fun(a_track.dizziness_stu, a_track.soldier_name)
    a_track.silence_stu = liberate.during_silence_fun(a_track.silence_stu, a_track.soldier_name)

    print(' ')
    time.sleep(2)

    #computer time

    b_track.health_discribe()
    time.sleep(2)

    b_track.blood,b_track.poison_stu = liberate.during_poison_fun(b_track.blood, b_track.poison_stu, b_track.soldier_name)
    if b_track.blood == 0:
        b_track.death_discribe()
        a_track.winner_discribe()
        break
    time.sleep(2)

    b_track.magic, b_track.blood, a_track.blood, b_track.dizziness_stu, b_track.silence_stu, b_track.poison_stu, \
    a_track.dizziness_stu, a_track.silence_stu, a_track.poison_stu, b_skill_name = \
        liberate.com_libr_skill(b_track.magic, b_track.blood, a_track.blood,
                                      b_track.dizziness_stu, b_track.silence_stu, b_track.poison_stu,
                                      a_track.dizziness_stu, a_track.silence_stu, a_track.poison_stu,
                                      b_track.soldier_name, a_track.soldier_name, b_track.skills)
    if a_track.blood == 0:
        a_track.death_discribe()
        b_track.winner_discribe()
        break

    if b_track.dizziness_stu == 0 and b_skill_name == 'pk_info':
        a_track.blood = b_track.pk_info(a_track.blood, b_track.soldier_name, a_track.soldier_name)
    else:
        pass
    if a_track.blood == 0:
        a_track.death_discribe()
        b_track.winner_discribe()
        break

    b_track.dizziness_stu = liberate.during_dizziness_fun(b_track.dizziness_stu, b_track.soldier_name)
    b_track.silence_stu = liberate.during_silence_fun(b_track.silence_stu, b_track.soldier_name)

    times += 1
    time.sleep(2)
    if b_track.magic < 8:
        b_track.magic += 2
    else:
        b_track.magic = 10
    if a_track.magic < 8:
        a_track.magic += 2
    else:
        a_track.magic = 10
    print(' ')
    print('********************************************')
    a_track.health_discribe()
    time.sleep(2)
    b_track.health_discribe()
    print('********************************************')
    next_set = input("input anything to continue!")

    print(' ')
    time.sleep(2)

#    print("stop!")
#    break


